import yaml

from zs_config.common import LocalFilesystemLoader, iterate_loaders

class LocalSchemaLoader(LocalFilesystemLoader):
    def get_load_paths(self):
        return self.bootstrap_cfg.schema.local.schema_paths

    def proc_file_data(self, file_handle):
        return yaml.safe_load(file_handle)

    def get_file_type(self):
        return 'schema'

_loader_class_map = {
    'local': LocalSchemaLoader,
}

def load_schemas(bootstrap_cfg):
    return iterate_loaders(bootstrap_cfg.schema.loaders,
                           _loader_class_map, (bootstrap_cfg,))

